<template>
  <div class="help-container">
    <div class="container">
      <div class="privacy-header-title">
        <!-- 常见问题 -->
        <div>FAQs</div>
        <div class="last-updated">Below are some common concerns of our clients before purchasing.
          <br>
           <strong>If you have other questions, please just send them to support@lunruo.com</strong></div>
      </div>
      <div class="privacy-content">
        <div v-for="(item, index) in privacyItems" :key="index" class="privacy-item">
          <div class="privacy-header" @click="toggleContent(index,item.key)">
            <h2>{{ item.title }}</h2>
            <span class="arrow" :class="{ 'arrow-up': openIndex === index }">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                  stroke-linejoin="round" />
              </svg>
            </span>
          </div>
          <div class="privacy-body" v-show="openIndex === index">
            <div class="content" v-html="item.content"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref ,onMounted} from 'vue';
import { getAgreement } from '@/api/help';

const openIndex = ref<number | null>(null);
// onMounted(async () => {
  
//   // 处理数据...
// });
const keyValue = ref('')
const toggleContent = (index: number,key:string) => {
  openIndex.value = openIndex.value === index ? null : index;
  keyValue.value = key
  // 在这里调用接口获取数据
  getAgreement(keyValue.value).then((res: any) => {
    privacyItems.value.forEach(item=>{
      item.content = res.data
    });
  });
};

const privacyItems = ref([
  {
    key: 'general',
    title: 'general',
    content: ``

  },
  {
    key: 'site_licence',
    title: 'Site Licence',
    content: ``
  },
  {
    key: 'application_and_account_details',
    title: 'Application and Account Details',
    content: ``
  },
  {
    key: 'mailing_list',
    title: 'Mailing List',
    content: ``
  },
  {
    key: 'shipping_and_risk_of_loss',
    title: 'Shipping And Risk Of Loss',
    content: ``
  },
  {
    key: 'offers_sale_black_friday_terms_and_conditions',
    title: 'Offers/Sale/Black Friday Terms And Conditions',
    content: ``
  },
  {
    key: 'delivery',
    title: 'Delivery',
    content: ``
  },
  // {
  //   key: 'duonin_com_us_gift_card_t_c',
  //   title: "REISS.com US - Gift Card T&C’s",
  //   content: ``
  // },
  {
    key: 'returns_and_refunds',
    title: 'Returns And Refunds',
    content: ``
  },
  {
    key: 'prices',
    title: 'Prices',
    content: ``
  },
  {
    key: 'availability',
    title: 'Availability',
    content: ``
  },
  {
    key: 'product_descriptions',
    title: 'Product Descriptions',
    content: ``
  },


  {
    key: 'copyright_and_trademarks',
    title: 'Copyright And Trademarks',
    content: ``
  },
  {
    key: 'copyright_complaints',
    title: 'Copyright Complaints',
    content: ``
  },
  {
    key: 'credit_card_payments',
    title: 'Credit Card Payments',
    content: ``
  },
  {
    key: 'voucher_pins_with_money_or_a_percentage_off',
    title: 'Voucher PINs With Money Or A Percentage Off',
    content: ``
  },
  {
    key: 'customs_fees',
    title: 'Customs Fees',
    content: ``
  },
  {
    key: 'links_to_other_sites',
    title: 'Links To Other Sites',
    content: ``
  },


  {
    key: 'disclaimer_of_warranties_and_limitation_of_liability',
    title: 'Disclaimer Of Warranties And Limitation Of Liability',
    content: ``
  },
  {
    key: 'governing_law_and_jurisdiction',
    title: 'Governing Law And Jurisdiction',
    content: ``
  },
  {
    key: 'modifications',
    title: 'Modifications',
    content: ``
  },
  {
    key: 'electronic_communications',
    title: 'Electronic Communications',
    content: ``
  },
]);
</script>

<style scoped lang="scss">
.help-container {
  width: 100%;
  min-height: 100vh;
  background-color: #fff;
  padding: 20px 0;
  margin: 0 auto;
  margin-bottom: 90px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;

  @media (max-width: 1280px) {
    padding: 0 15px;
    width: 100%;
  }
}

.privacy-header-title {
  border-bottom: 1px solid #e0e0e0;
  font-size: 24px;
  color: #000;
  text-align: center;
  letter-spacing: 0.4px;
  font-weight: 400;
  padding-bottom: 20px;

  .last-updated {
    font-size: 13px;
    margin-top: 20px;
  }
}

.privacy-content {
  max-width: 100%px;
  margin: 0 auto;
}

.privacy-item {
  border-bottom: 1px solid #e0e0e0;

  &:last-child {
    border-bottom: none;
  }
}

.privacy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  color: #525252;
  cursor: pointer;

  h2 {
    font-size: 18px;
    font-weight: 400;
    margin: 0;
    color: #000;
    letter-spacing: 0.8px;
  }

  .arrow {
    transition: transform 0.3s ease;
    color: #666;

    &.arrow-up {
      transform: rotate(180deg);
    }
  }

  &:hover {
    h2 {
      color: #000;
    }

    .arrow {
      color: #525252;
    }
  }
}

.privacy-header {
  text-align: center;
  // margin-bottom: 40px;

  height: 66px;

  h1 {
    font-size: 26px;
    font-weight: bold;
    margin-bottom: 10px;

    @media (max-width: 1280px) {
      font-size: 24px;
    }
  }

  .last-updated {
    font-size: 16px;
    color: #000;

    @media (max-width: 1280px) {
      font-size: 14px;
    }
  }
}

.privacy-body {
  padding-bottom: 20px;

  .content {
    color: #666;
    font-size: 14px;
    line-height: 1.6;

    p {
      margin-bottom: 15px;

      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}
</style>